package com.ziyun.erp.web.modules.order.controller;

import com.ziyun.erp.modules.order.entity.UserPaymentBillEntity;
import com.ziyun.erp.modules.order.service.UserPaymentBillService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 用户支付关联表
 *
 * @author guizhao
 * @email ...
 * @date 2018-08-06 11:45:03
 */
@RestController
@RequestMapping("order/userpaymentbill")
public class UserPaymentBillController {
    @Autowired
    private UserPaymentBillService userPaymentBillService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("order:userpaymentbill:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userPaymentBillService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{relId}")
    @RequiresPermissions("order:userpaymentbill:info")
    public R info(@PathVariable("relId") Long relId){
        UserPaymentBillEntity userPaymentBill = userPaymentBillService.selectById(relId);

        return R.ok().put("userPaymentBill", userPaymentBill);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("order:userpaymentbill:save")
    public R save(@RequestBody UserPaymentBillEntity userPaymentBill){
        userPaymentBillService.insert(userPaymentBill);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("order:userpaymentbill:update")
    public R update(@RequestBody UserPaymentBillEntity userPaymentBill){
        ValidatorUtils.validateEntity(userPaymentBill);
        userPaymentBillService.updateAllColumnById(userPaymentBill);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("order:userpaymentbill:delete")
    public R delete(@RequestBody Long[] relIds){
        userPaymentBillService.deleteBatchIds(Arrays.asList(relIds));

        return R.ok();
    }

}
